
DEFINE MISSIONS 1              // Total Missions Available
DEFINE MISSION 0 AT @MISSN_15  
  

DEFINE EXTERNAL_SCRIPTS 0 

DEFINE UNKNOWN_EMPTY_SEGMENT 0

DEFINE UNKNOWN_THREADS_MEMORY 500

{$VERSION 3.1.0027}
var
 $PLAYER_CHAR: Player
end // var 
//Main thread starts here
03A4: name_thread 'MAIN' 
//Set the screen BLACK immediately
016A: fade 0 time 0           
01F0: set_max_wanted_level_to 6 
0111: toggle_wasted_busted_check 0 
00C0: set_current_time_hours_to 8 minutes_to 0 
//Loads Tenpenny as #SPECIAL01 or 290
023C: load_special_actor 'TENPEN' as 1 
//Create Player at Station
Camera.SetAtPos(1930.425, -2442.2119, 14.0557)  
$PLAYER_CHAR = Player.Create(#NULL, 1408.1317, -2261.6375, 13.5469)
Player.Build($PLAYER_CHAR)
//Changes the player to ped model 290 Tenpenny
09C7: change_player $PLAYER_CHAR model_to 290 
01F5: $PLAYER_ACTOR = create_player_actor $PLAYER_CHAR 
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group 

01B6: set_weather 1 
0001: wait 0 ms 
01B4: toggle_player $PLAYER_CHAR can_move false //We shut down control for the cameras to work 
04BB: select_interior 0 
0629: change_integer_stat 181 to 4 
016C: restart_if_wasted_at 1408.1317 -2261.6375 13.5469 angle 90.0 town_number 0 
016D: restart_if_busted_at 1408.1317 -2261.6375 13.5469 angle 90.0 town_number 0 
// Note: your missions have to use the variable defined here
0180: set_on_mission_flag_to $ONMISSION 
$ONMISSION = 0 
0004: $DEFAULT_WAIT_TIME = 250
03E6: remove_text_box 
// START GAME
//start_mission 0                 //First Mission and Only Mission
$CRASH_MARKER = Marker.CreateIconAndSphere(16, 1443.7655, -2287.178, 13.5469)
016A: fade 1 time 500
wait 1000
01B4: toggle_player $PLAYER_CHAR can_move true
 
:MAIN_LOOP
0001: wait $DEFAULT_WAIT_TIME ms
00BF: $TIME_HOURS = current_time_hours, $TIME_MINS = current_time_minutes
//This code allows restart of mission 

if and
  $ONMISSION == 0               //No current mission and enters the sphere
  00ED: actor $PLAYER_ACTOR 0 near_point 1443.7655 -2287.178 radius 2.0 2.0 on_foot 
then
    //016A: fade 0 time 500 
    //0001: wait 1000 ms
    Marker.Disable($CRASH_MARKER)   //Turn off the marker on the map and the red ring
    start_mission 0 
end

0002: jump @MAIN_LOOP 

:MISSN_15
thread 'MISSN_15' 
$ONMISSION = 1
gosub @MISSN_15_200            // Start Mission
            
if 
    wasted_or_busted            
then
    $CRASH_MARKER = Marker.CreateIconAndSphere(16, 1443.7655, -2287.178, 13.5469)
end
gosub @MISSN_15_2720             // End Mission Destroy All
end_thread 

:MISSN_15_200 
016A: fade 0 time 0 
:MISSN_15_205
wait 0
if 
not fading
jf @MISSN_15_205
//First cut boarding the plane.
0247: load_model #AT400
Model.Load(#WFYCLOT)
:MISSN_15_210
wait 0
if and
0248:   model #AT400 available 
Model.Available(#WFYCLOT)
jf @MISSN_15_210

00A5: 120@ = create_car #AT400 at 1901.7 -2391.0 13.5547
0175: set_car 120@ Z_angle_to 94.856 
0129: 121@ = create_actor_pedtype 24 model #WFYCLOT in_car 120@ driverseat 
0376: 122@ = create_random_actor_at 1882.0356 -2402.5303 13.5547 
0376: 122@ = create_random_actor_at 1882.2356 -2404.5303 13.5547 
0376: 122@ = create_random_actor_at 1882.1356 -2405.5303 13.5547 
0376: 122@ = create_random_actor_at 1882.3356 -2407.5303 13.5547 
0376: 122@ = create_random_actor_at 1882.1356 -2409.5303 13.5547 
Actor.PutAt($PLAYER_ACTOR ,1882.0356, -2400.5303, 13.5547)
Actor.Angle($PLAYER_ACTOR) = 0.5
067C: put_camera_on_actor $PLAYER_ACTOR with_offset -4.0 -13.0 5.0 rotation 0.0 0.0 0.0 0.0 2 
01B4: set_player $PLAYER_CHAR can_move false 
054C: use_GXT_table 'JABM15' 

wait 2500
02A3: enable_widescreen 1 
016A: fade 1 time 2500 
:MISSN_15_212
wait 0
if 
not fading
jf @MISSN_15_212

00BC: show_text_highpriority GXT 'JA01' time 3000 flag 1  // Nothing like a relaxing vaction in Las Venturas.
wait 3500 
00BC: show_text_highpriority GXT 'JA02' time 4000 flag 1  // Gambling, hookers, drugs, and beer now that has got to be the best way to spend down time.
wait 4500 
0430: put_actor $PLAYER_ACTOR into_car 120@ passenger_seat 0 

:MISSN_15_215
wait 0
if 
00DB:   actor $PLAYER_ACTOR in_car 120@ 
jf @MISSN_15_215

Car.PutAt(120@, 1400.8928, -2494.0078, 190.5391)
04D2: set_plane 120@ fly_autopilot_around_point 328.9085 2017.646 400.0 altitude_between 0.0 and 250.0 
Camera.Restore_WithJumpCut
Camera.SetBehindPlayer
00BC: show_text_highpriority GXT 'JA03' time 5000 flag 1  // Attention passengers, there has been a slight mishap in the cargo hold.
03CF: load_wav 44618 as 1 
gosub @MISSN_15_PLAYSND
00BC: show_text_highpriority GXT 'JA04' time 5000 flag 1  // A box of snakes is loose on this aircarft, should you see any snakes please do not touch them.
03CF: load_wav 44619 as 1 
gosub @MISSN_15_PLAYSND 
00BC: show_text_highpriority GXT 'JA05' time 5000 flag 1  // Thank you, and enjoy your flight.
03CF: load_wav 44620 as 1 
gosub @MISSN_15_PLAYSND 
00BC: show_text_highpriority GXT 'JA06' time 5000 flag 1  // Excuse me officer but, do you have any skill as a pilot? Can you fly a plane?
03CF: load_wav 44621 as 1 
gosub @MISSN_15_PLAYSND 
00BC: show_text_highpriority GXT 'JA07' time 5000 flag 1  // Officer look out a snake!
03CF: load_wav 44622 as 1 
gosub @MISSN_15_PLAYSND
00BC: show_text_highpriority GXT 'JA08' time 7000 flag 1  // What a pretty snake... like a rainbow... pretty snake... Sure I can fly, without a plane.
03CF: load_wav 44623 as 1 
gosub @MISSN_15_PLAYSND 
:MISSN_15_220
wait 0
0819: 7@ = actor $PLAYER_ACTOR distance_from_ground 
 
if 
7@ > 300.0
jf @MISSN_15_220
//Fade out
016A: fade 0 time 0 
:MISSN_15_230
wait 0
if 
not fading
jf @MISSN_15_230
 
068B: set_car 120@ all_disembark 
:MISSN_15_240
wait 0
if 
80DB:   not actor $PLAYER_ACTOR in_car 120@ 
jf @MISSN_15_240
00A6: destroy_car 120@ 

04ED: load_animation "PARACHUTE" 
:MISSN_15_250
wait 0
if
04EE:   animation "PARACHUTE" loaded 
jf @MISSN_15_250
08B2: enable_thermal_vision true 
03CF: load_wav 44600 as 1 
03CF: load_wav 44601 as 2 
:MISSN_15_260
wait 0
if  and
03D0:   wav 1 loaded 
03D0:   wav 2 loaded 
jf @MISSN_15_260
98@ = 44602
99@ = 1
083C: set_actor $PLAYER_ACTOR velocity_in_direction_XYZ 0.0 0.0 0.0  
067C: put_camera_on_actor $PLAYER_ACTOR with_offset 0.0 -3.0 1.0 rotation 0.0 0.0 0.0 0.0 2 
03D1: play_wav 1 
018A: 43@ = create_checkpoint_at 1477.4657 1464.806 10.8203 
01B4: set_player $PLAYER_CHAR can_move true
02A3: enable_widescreen 0
016A: fade 1 time 0 
:MISSN_15_270
wait 0
if 
not fading
jf @MISSN_15_270

03E5: show_text_box 'JA09'  
//Main Loopy Snake bite enduced hallucination. 
:MISSN_15_1300
wait 0
//Tenpenny flys without an airplane
083D: get_actor $PLAYER_ACTOR velocity_in_direction_XYZ $1507 $1508 $1509 
0819: 7@ = actor $PLAYER_ACTOR distance_from_ground 
//Chopped up music is "White Rabbit" by Jefferson Airplane
//My brother injected the song but the whole song didn't fit.
//So he chopped it up into 16 blocks, less than 12 seconds each.
//If you use professional music in your mods you need to get the
//copyright holders permission.  But even if they say no, you can
//still use it since it is for non-profit use, it falls under the
//"Fair Use Act" US and UK copyright law section. 
//http://www.copyright.gov/fls/fl102.html
if and
99@ == 1
03D2:   wav 1 ended 
then
03D1: play_wav 2 
040D: unload_wav 1 
03CF: load_wav 98@ as 1

:MISSN_15_1320
wait 0
if
03D0:   wav 1 loaded 
jf @MISSN_15_1320
98@ += 1
99@ = 0 
end
//This block, like the block above, plays the next wav and gets
//the next chunk loaded into wav 2. You may hear the cuts in the
//music if your PC lags.
if and
99@ == 0
03D2:   wav 2 ended 
then 
03D1: play_wav 1 
040D: unload_wav 2
03CF: load_wav 98@ as 2

:MISSN_15_1330
wait 0
if
03D0:   wav 2 loaded 
jf @MISSN_15_1330
98@ += 1
99@ = 1
if 
98@ > 44616         //End of Song
then
99@ = 2             //Stop checking to play.
040D: unload_wav 1
040D: unload_wav 2
end 
end  //End of music checking
//check the Player's rotation 
1@ = Actor.Angle($PLAYER_ACTOR) 
//Rotation using input from either pad, stick or keyboard.
0494: get_joystick 0 data_to 10@ 11@ 12@ 12@ 
if 
10@ == 0
then
0812: AS_actor $PLAYER_ACTOR perform_animation "FALL_SKYDIVE_ACCEL" IFP_file "PARACHUTE" 1.0 loopA 1 lockX 0 lockY 0 lockF 0 time 250 
end
if 
  10@ > 0 
then
1@ -= 1.0
0812: AS_actor $PLAYER_ACTOR perform_animation "FALL_SKYDIVE_R" IFP_file "PARACHUTE" 1.0 loopA 1 lockX 0 lockY 0 lockF 0 time 250 
end
if 
  0 > 10@ 
then
1@ += 1.0
0812: AS_actor $PLAYER_ACTOR perform_animation "FALL_SKYDIVE_L" IFP_file "PARACHUTE" 1.0 loopA 1 lockX 0 lockY 0 lockF 0 time 250 
end
//keeps degrees on track 0.0 to 359.99
if 1@ < 0.0 
then
1@ += 360.0
end 
if 1@ > 360.0 
then
1@ -= 360.0
end

Actor.Angle($PLAYER_ACTOR) = 1@
00A0: store_actor $PLAYER_ACTOR position_to $TEMPVAR_FLOAT_a $TEMPVAR_FLOAT_b $TEMPVAR_FLOAT_c 
//This part is also used in 16 Flying Elvis, however the control is more like a plane here. 
//Forward motion is a constant.
02F6: $TEMPVAR_FLOAT_1 = cosine 1@ 
02F7: $TEMPVAR_FLOAT_2 = sine 1@ 
$TEMPVAR_FLOAT_1 *= -1.0
//Increase descent
if 
11@ < 0
then
$1509 -= 5.0 
end
//Decrease descent
if
11@ > 0 
then
$1509 += 5.0
end

0059: $1507 += $TEMPVAR_FLOAT_1 
0059: $1508 += $TEMPVAR_FLOAT_2 

//Move Tenpenny the direction needed
083C: set_actor $PLAYER_ACTOR velocity_in_direction_XYZ $1507 $1508 $1509  

//Repeat until landing at airport or less than 10.0 meters above ground or you died
if or
Actor.Dead($PLAYER_ACTOR) 
7@ < 10.0
jf @MISSN_15_1300
//Switch back to plane
016A: fade 0 time 0 
:MISSN_15_1335
wait 0
if 
not fading
jf @MISSN_15_1335
Actor.PutAt($PLAYER_ACTOR,1477.4657, 1464.806, 10.8203)
00A5: 120@ = create_car #AT400 at 1477.4657 1564.806 10.8203
08B2: enable_thermal_vision false 
wait 500
072A: put_actor $PLAYER_ACTOR into_car 120@ driverseat
:MISSN_15_1350
wait 0
if
Actor.DrivingPlane($PLAYER_ACTOR)
jf @MISSN_15_1350
//$TEMPVAR_FLOAT_c += 50
Car.PutAt(120@, $TEMPVAR_FLOAT_a, $TEMPVAR_FLOAT_b, $TEMPVAR_FLOAT_c) 
0175: set_car 120@ Z_angle_to 1@ 
07D5: set_car 120@ velocity_in_direction_XYZ $1507 $1508 $1509 rotation_velocitiesXY 0.0 0.0 unk 0.0  
016A: fade 1 time 0 
:MISSN_15_1355
wait 0
if 
not fading
jf @MISSN_15_1355
Camera.Restore_WithJumpCut
040D: unload_wav 1
040D: unload_wav 2
99@ = 0
//Airport?
if
80FE:   not actor $PLAYER_ACTOR sphere 0 in_sphere 1477.4657 1464.806 10.8203 radius 330.0 330.0 330.0  
jf @MISSN_15_2650    

//You're a LOSER! 
:MISSN_15_2600
0209: 99@ = random_int_in_ranges 44624 44628 
03CF: load_wav 99@ as 1
gosub @MISSN_15_PLAYSND
Car.Health(120@) = 0
Actor.Health($PLAYER_ACTOR) = 1
00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
//This is point to return to the station and retry the mission.
$CRASH_MARKER = Marker.CreateIconAndSphere(16, -1635.8995, 721.0715, 14.6169)
return
//Land Plane
:MISSN_15_2650  
wait 0
if
not Actor.Dead($PLAYER_ACTOR)
jf @MISSN_15_2600
if 
99@ == 0
then
Camera.SetBehindPlayer
03CF: load_wav 44628 as 1
gosub @MISSN_15_PLAYSND
03E5: show_text_box 'JA10'  
99@ = 1
end
if 
84AB:   not actor $PLAYER_ACTOR driving_plane 
jf @MISSN_15_2650
         
:MISSN_15_2700
030C: progress_made += 1 
0394: play_music 1 
Player.ClearWantedLevel($PLAYER_CHAR)
01E3: show_text_1number_styled GXT 'M_PASSR' number 7 time 5000 style 1  
wait 5000 
return 

:MISSN_15_PLAYSND
wait 0
if 
03D0:   wav 1 loaded 
jf @MISSN_15_PLAYSND
03D1: play_wav 1 
:MISSN_15_PLAYING
wait 0
if 
03D2:   wav 1 ended 
jf @MISSN_15_PLAYING
040D: unload_wav 1 
return

:MISSN_15_2720
$ONMISSION = 0 
01BD: $CURRENT_TIME_IN_MS = current_time_in_ms
0164: disable_marker 43@ 
mission_cleanup 
return 

